//
//  NYMainViewModel.m
//  Nooryes
//
//  Created by baken on 2020/2/29.
//  Copyright © 2020 MyApp. All rights reserved.
//

#import "NYMainViewModel.h"
#import "NYMainManager.h"
#import "NYMainModel.h"
#import "NYVersionModel.h"

@implementation NYMainViewModel

- (void)checkVersionWithConplationHandle:(CompletionHandle)complete{
    [NYMainManager checkVersionWithCompletionHandle:^(NYVersionModel *model, NSError *error) {
        if (!error) {
            myDelegate.aboutUrl = model.data.about;
            myDelegate.isDisplay = model.data.ps;
            NSString *nowVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
            float sVersion = [model.data.version floatValue];
            float fnowVersion = [nowVersion floatValue];
            if (fnowVersion < sVersion) {
                self.isUpdate = YES;
            }
            self.versionModel = model.data;
            myDelegate.aboutUrl = model.data.about;
        }
        complete(error);
    }];
}
@end
